package com.itwk.gulimall.coupon.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itwk.common.to.SkuReductionTo;
import com.itwk.common.utils.PageUtils;
import com.itwk.common.utils.Query;
import com.itwk.gulimall.coupon.dao.SmsSkuFullReductionDao;
import com.itwk.gulimall.coupon.dao.SmsSkuLadderDao;
import com.itwk.gulimall.coupon.entity.SmsSkuFullReductionEntity;
import com.itwk.gulimall.coupon.service.SmsSkuFullReductionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("smsSkuFullReductionService")
public class SmsSkuFullReductionServiceImpl extends ServiceImpl<SmsSkuFullReductionDao, SmsSkuFullReductionEntity> implements SmsSkuFullReductionService {
@Autowired
    private SmsSkuLadderDao ladderDao;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SmsSkuFullReductionEntity> page = this.page(
                new Query<SmsSkuFullReductionEntity>().getPage(params),
                new QueryWrapper<SmsSkuFullReductionEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void saveRuctionWithLadder(SkuReductionTo skuReductionTo) {
        //保存reduction 满几件打几折
        SmsSkuFullReductionEntity reductionEntity = new SmsSkuFullReductionEntity();
        BeanUtils.copyProperties(skuReductionTo, reductionEntity);
        reductionEntity.setAddOther(skuReductionTo.getPriceStatus());
        baseMapper.insert(reductionEntity);

    }

}